from django.db import models
from django.utils import timezone


class TranslateToHex(models.Model):
    """
    存储字符串到十六进制转换记录
    """
    original_string = models.TextField(verbose_name="原始字符串")
    hex_string = models.TextField(verbose_name="十六进制字符串")
    created_at = models.DateTimeField(default=timezone.now, verbose_name="创建时间")

    class Meta:
        verbose_name = "字符串转十六进制记录"
        verbose_name_plural = "字符串转十六进制记录"
        ordering = ['-created_at']  # 按创建时间降序排列

    def __str__(self):
        return f"{self.original_string[:20]}... -> {self.hex_string[:20]}..."